﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;

namespace PServiceBus.Core.Configuration {
    internal class WebStreamManagementElement : ConfigurationElement, PServiceBus.Core.Interface.IWebStreamManagementConfig {
        public WebStreamManagementElement() { }
        public WebStreamManagementElement(string name) { Name = name; }
        [ConfigurationProperty("name", IsRequired = true, IsKey = true)]
        public string Name {
            get { return base["name"] as string; }
            set { base["name"] = value; }
        }
        [ConfigurationProperty("type", IsRequired = true)]
        public string Type {
            get { return base["type"] as string; }
            set { base["type"] = value; }
        }
    }
    [ConfigurationCollection(typeof(WebStreamManagementElement), CollectionType = ConfigurationElementCollectionType.BasicMap)]
    internal sealed class WebStreamManagementCollection : ConfigurationElementCollection {
        protected override ConfigurationElement CreateNewElement() {
            return new WebStreamManagementElement();
        }

        protected override object GetElementKey(ConfigurationElement element) {
            return (element as WebStreamManagementElement).Name;
        }
    }
    public sealed class WebStreamManagementConfigSection : ConfigurationSection {
        [ConfigurationProperty("streams", IsDefaultCollection = true, IsRequired = true)]
        internal WebStreamManagementCollection Streams {
            get { return this["streams"] as WebStreamManagementCollection; }
        }
    }
}
